bitkeeper revision 1.1144.2.1 (41111749FSr1gr4vfGeXBFEKdMTxNw)
authorcl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>
Wed, 4 Aug 2004 17:05:13 +0000 (17:05 +0000)
committercl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>
Wed, 4 Aug 2004 17:05:13 +0000 (17:05 +0000)
Allow a dom0 kernel to run as domU.

linux-2.6.7-xen-sparse/arch/xen/i386/kernel/setup.c
linux-2.6.7-xen-sparse/arch/xen/i386/mm/init.c
linux-2.6.7-xen-sparse/drivers/xen/console/console.c
linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/fixmap.h
linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/io.h

index e2fea04403eeb76b60c7035f3c8c4c737ee65440..27a3e4f19275f8cede595a40d88049f3603291b3 100644 (file)
@@ -924,7 +924,7 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
 {
        int i;
 
-#ifdef CONFIG_XEN_PHYSDEV_ACCESS
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
        probe_roms();
 #endif
        for (i = 0; i < e820.nr_map; i++) {
@@ -1215,15 +1215,6 @@ void __init setup_arch(char **cmdline_p)
 
        register_memory(max_low_pfn);
 
-#ifdef CONFIG_VT
-#if defined(CONFIG_VGA_CONSOLE)
-       if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
-               conswitchp = &vga_con;
-#elif defined(CONFIG_DUMMY_CONSOLE)
-       conswitchp = &dummy_con;
-#endif
-#endif
-
        /* If we are a privileged guest OS then we should request IO privs. */
        if (start_info.flags & SIF_PRIVILEGED) {
                dom0_op_t op;
@@ -1234,6 +1225,27 @@ void __init setup_arch(char **cmdline_p)
                        panic("Unable to obtain IOPL, despite SIF_PRIVILEGED");
                current->thread.io_pl = 1;
        }
+
+       if (start_info.flags & SIF_INITDOMAIN) {
+               if (!(start_info.flags & SIF_PRIVILEGED))
+                       panic("Xen granted us console access "
+                             "but not privileged status");
+
+#ifdef CONFIG_VT
+#if defined(CONFIG_VGA_CONSOLE)
+               if (!efi_enabled ||
+                   (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
+                       conswitchp = &vga_con;
+#elif defined(CONFIG_DUMMY_CONSOLE)
+               conswitchp = &dummy_con;
+#endif
+#endif
+       } else {
+#if defined(CONFIG_VGA_CONSOLE)
+               /* disable VGA driver */
+               ORIG_VIDEO_ISVGA = VIDEO_TYPE_VLFB;
+#endif
+       }
 }
 
 #include "setup_arch_post.h"
index 37c3b8ec25b3863d81626059a3711186351f35ec..779a25073de70e9e8ef64b78bf4994bbe20b1856 100644 (file)
@@ -502,7 +502,11 @@ void __init paging_init(void)
 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
        /* Setup mapping of lower 1st MB */
        for (i = 0; i < NR_FIX_ISAMAPS; i++)
-               set_fixmap_ma(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
+               if (start_info.flags & SIF_PRIVILEGED)
+                       set_fixmap_ma(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
+               else
+                       set_fixmap_ma_ro(FIX_ISAMAP_BEGIN - i,
+                                        virt_to_machine(empty_zero_page));
 #endif
 }
 
index f6c2e64790f358da764173d374cb44cdf37ced7d..368e437be42a9d7cbc952e19679f8e003552568f 100644 (file)
@@ -45,6 +45,10 @@ static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT;
 
 static int __init xencons_setup(char *str)
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+    if (str[0] == '=')
+       str++;
+#endif
     if ( !strcmp(str, "tty") )
         xc_mode = XC_TTY;
     else if ( !strcmp(str, "ttyS") )
@@ -160,7 +164,14 @@ void xen_console_init(void)
     else
     {
         if ( xc_mode == XC_DEFAULT )
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && defined(CONFIG_VT)
+            /* On a kernel built with VT support, default to serial
+             * console because the VT driver has already allocated the
+             * /dev/tty device nodes */
+            xc_mode = XC_SERIAL;
+#else
             xc_mode = XC_TTY;
+#endif
         kcons_info.write = kcons_write;
     }
 
index 75bc078ec09abb4e090d5f34051e98a38e6cb951..0bfb839f2028dbb28e01c2d1cb1fd0fa857f3928 100644 (file)
@@ -98,6 +98,8 @@ extern void __set_fixmap_ma (enum fixed_addresses idx,
                __set_fixmap(idx, phys, PAGE_KERNEL)
 #define set_fixmap_ma(idx, phys) \
                __set_fixmap_ma(idx, phys, PAGE_KERNEL)
+#define set_fixmap_ma_ro(idx, phys) \
+               __set_fixmap_ma(idx, phys, PAGE_KERNEL_RO)
 /*
  * Some hardware wants to get fixmapped without caching.
  */
index 8701bcc5ce6c8abdfcc1fc793583339ee7a8f892..5b6604b6961dbddad47dd25b55b977ba19a547cf 100644 (file)
@@ -285,8 +285,15 @@ static inline void flush_write_buffers(void)
 
 #ifdef SLOW_IO_BY_JUMPING
 #define __SLOW_DOWN_IO "jmp 1f; 1: jmp 1f; 1:"
-#else
+#elif defined(__UNSAFE_IO__)
 #define __SLOW_DOWN_IO "outb %%al,$0x80;"
+#else
+#define __SLOW_DOWN_IO "\n1: outb %%al,$0x80\n"                \
+                      "2:\n"                           \
+                      ".section __ex_table,\"a\"\n\t"  \
+                      ".align 4\n\t"                   \
+                      ".long 1b,2b\n"                  \
+                      ".previous"
 #endif
 
 static inline void slow_down_io(void) {
@@ -320,7 +327,7 @@ static inline unsigned type in##bwl##_quad(int port, int quad) { \
 static inline unsigned type in##bwl(int port) { \
        return in##bwl##_quad(port, 0); \
 }
-#else
+#else 
 #define __BUILDIO(bwl,bw,type) \
 static inline void out##bwl(unsigned type value, int port) { \
        out##bwl##_local(value, port); \
@@ -331,7 +338,8 @@ static inline unsigned type in##bwl(int port) { \
 #endif
 
 
-#define BUILDIO(bwl,bw,type) \
+#if __UNSAFE_IO__
+#define ____BUILDIO(bwl,bw,type) \
 static inline void out##bwl##_local(unsigned type value, int port) { \
        __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \
 } \
@@ -339,7 +347,35 @@ static inline unsigned type in##bwl##_local(int port) { \
        unsigned type value; \
        __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \
        return value; \
+}
+#else
+#define ____BUILDIO(bwl,bw,type) \
+static inline void out##bwl##_local(unsigned type value, int port) { \
+       __asm__ __volatile__("1: out" #bwl " %" #bw "0, %w1\n"          \
+                            "2:\n"                                     \
+                            ".section __ex_table,\"a\"\n\t"            \
+                            ".align 4\n\t"                             \
+                            ".long 1b,2b\n"                            \
+                            ".previous" : : "a"(value), "Nd"(port));   \
 } \
+static inline unsigned type in##bwl##_local(int port) { \
+       unsigned type value; \
+       __asm__ __volatile__("1:in" #bwl " %w1, %" #bw "0\n"            \
+                            "2:\n"                                     \
+                            ".section .fixup,\"ax\"\n"                 \
+                            "3: mov" #bwl " $~0,%" #bw "0\n\t"         \
+                            "jmp 2b\n"                                 \
+                            ".previous\n"                              \
+                            ".section __ex_table,\"a\"\n\t"            \
+                            ".align 4\n\t"                             \
+                            ".long 1b,3b\n"                            \
+                            ".previous" : "=a"(value) : "Nd"(port));   \
+       return value; \
+}
+#endif
+
+#define BUILDIO(bwl,bw,type) \
+____BUILDIO(bwl,bw,type) \
 static inline void out##bwl##_local_p(unsigned type value, int port) { \
        out##bwl##_local(value, port); \
        slow_down_io(); \